<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %><!-- 数据库操作需要 -->      
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String repair_id=request.getParameter("id");//取得传递过来的用户参数，用于查询和删除
int repair_id1=Integer.parseInt(repair_id);
System.out.println(repair_id);
Connection conn=null;
try{
	Class.forName("org.h2.Driver");//加载驱动
} catch (ClassNotFoundException e) {
	e.printStackTrace();
	return;
}
try {
	conn = DriverManager.getConnection("jdbc:h2:d:/CompanyCar/temp/mydbtest", "sa", "");
	String sql="delete from car_repair where repair_id='"+repair_id1+"';"+"ALTER TABLE car_repair ALTER COLUMN repair_id RESTART WITH "+repair_id1;
	PreparedStatement pstmt  = conn.prepareStatement(sql);
	System.out.println(sql);
	//执行数据库插入，获取结果集
	int result=pstmt.executeUpdate();
	System.out.println(result);
	//关闭表达式对象
	pstmt.close();			
	//关闭数据库				
	conn.close();
} catch (SQLException e) {
	e.printStackTrace();
} finally{
//防止数据库未正常关闭
try{
	if (conn!=null && (!conn.isClosed())){
		conn.close();
	}
}catch(SQLException e){
	e.printStackTrace();
}
}
response.sendRedirect("D-Details_repair.jsp");
%>


</body>
</html>